<template>
  <div class="goodsDetail">
    <!-- 顶部导航 -->
    <van-nav-bar
      title="物品详情"
      left-text
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickRight"
      class="header"
    >
      <van-icon name="service" slot="right" />
    </van-nav-bar>

    <!-- 一口价销售中 -->
    <div class="sell_section">
      <div class="title_top">
        <h1 class="title_top_show">一口价销售中</h1>
      </div>
      <!-- 轮播图 -->
      <van-swipe :autoplay="2000" @change="onChange" class="banner">
        <van-swipe-item v-for="(image, index) in images" :key="index" class="banner_images">
          <img v-lazy="image" style="width: 100%;height: 100%;" />
        </van-swipe-item>

        <div class="custom-indicator" slot="indicator">
          <span class="count">{{ current + 1 }}/{{images.length}}</span>
        </div>
      </van-swipe>

      <div class="sell_section_info">
        <div class="sell_section_goodsInfo">
          <div class="goodsInfo_top">
            <span class="goodsInfo_grade">{{goods.goods_class}}</span>
            <h3 class="goodsInfo_title">{{goods.title}}</h3>
          </div>
          <p class="goodsInfo_info">{{goods.description}}</p>
          <span class="goodsInfo_price">￥{{goods.direct_price}}</span>
        </div>
        <div class="sell_section_rules">
          <p class="go_rules">
            <van-icon name="arrow" class="arrow" />
            <span class="words" @click="$router.push('/terraceRules')">一品数码会等级规则</span>
          </p>
        </div>
      </div>
    </div>

    <!-- 质检 -->
    <div class="quality_section">
      <div class="title_top">
        <h1 class="title_top_show">一品数码会质检</h1>
      </div>
      <div class="goods_code_group">
        <p class="goods_code">
          <span class="code_title">物品编号：</span>
          {{goods.goodscode}}
        </p>
        <p class="goods_code">
          <span class="code_title">IMEI：</span>
          {{goods.imei}}
        </p>
      </div>
      <!-- 质检报告 -->
      <div class="quality_report">
        <van-image :src="goods.reportImg" />
      </div>
    </div>

    <div class="footer_btn">
      <van-button type="default" class="btn">提交订单</van-button>
    </div>
  </div>
</template>

<script>
import { NavBar, Lazyload, Swipe, SwipeItem, Image, Button } from "Vant";
export default {
  name: "goodsDetail",
  data() {
    return {
      goods_id: '',
      current: 0,
      images: [], // 轮播图
      goods: {
        grade: "A2",
        title: "苹果iPhone XS max  大陆国行256G 保修",
        info: "苹果iPhone XS max  大陆国行256G 保修",
        price: "1,890.00",
        goodscode: "216716377153151141",
        imei: "CQYEUQGJJJCA",
        reportImg: require("@/assets/img/goodsDetail/good_detail.jpg")
      }
    };
  },
  created() {
    this.goods_id = this.$route.query.id
    this.getGoodsDetail()
  },
  methods: {
    // 获取商品详情
    getGoodsDetail() {
      this.$axios.get(`/api/index/directGoodsDetail?goods_id=${this.goods_id}`).then(res => {
        console.log(res)
        if (res.data.code === 1) {
          this.goods = res.data.data
          this.images = res.data.data.images.split(',')
        }
      })
    },
    // 顶部按钮
    onClickLeft() {
      this.$router.go(-1);
    },
    onClickRight() {
      console.log("按钮");
    },

    // 轮播图
    onChange(index) {
      this.current = index;
    }
  }
};
</script>

<style lang="less" scoped>
@deep: ~">>>";
.goodsDetail {
  width: 100%;
  padding-bottom: 171px;
  .header {
    width: 100%;
    height: 100px;
    @{deep} .van-icon {
      font-size: 19px;
      font-weight: 500;
      color: rgba(51, 51, 51, 1);
    }
    @{deep} .van-nav-bar__title {
      line-height: 50px;
      font-size: 18px;
      font-family: SourceHanSansCN;
      font-weight: 600;
      color: rgba(51, 51, 51, 1);
    }
  }
  .sell_section {
    width: 100%;
    background: rgba(255, 255, 255, 1);
    .title_top {
      height: 120px;
      padding: 39px 0 39px 30px;
      .title_top_show {
        font-size: 42px;
        font-family: PingFang SC;
        font-weight: bold;
        color: rgba(51, 51, 51, 1);
      }
    }
    .banner {
      width: 100%;
      height: 750px;
      .banner_images {
        width: 350px;
        height: 750px;
      }
      .custom-indicator {
        position: relative;
        bottom: 58px;
        left: 641px;
        width: 109px;
        height: 58px;
        text-align: center;
        line-height: 58px;
        background: rgba(0, 0, 0, 1);
        opacity: 0.4;
        .count {
          font-size: 28px;
          font-family: SourceHanSansCN;
          font-weight: 500;
          color: rgba(255, 255, 255, 1);
        }
      }
    }
    .sell_section_info {
      width: 100%;
      height: 327px;
      background: rgba(255, 255, 255, 1);
      .sell_section_goodsInfo {
        width: 690px;
        margin: 0 auto;
        padding-bottom: 23px;
        padding-top: 43px;
        border-bottom: 1px solid rgba(226, 226, 226, 1);
        .goodsInfo_top {
          height: 42px;
          .goodsInfo_grade {
            float: left;
            width: 80px;
            height: 42px;
            text-align: center;
            line-height: 42px;
            // background:linear-gradient(0deg,rgba(255,127,63,0.83));
            border-radius: 21px;
            background-color: #ff3b3e;
            font-size: 24px;
            font-family: SourceHanSansCN;
            font-weight: 500;
            color: rgba(255, 255, 255, 1);
          }
          .goodsInfo_title {
            float: left;
            height: 30px;
            font-size: 30px;
            margin-left: 19px;
            font-family: PingFang SC;
            font-weight: bold;
            color: rgba(51, 51, 51, 1);
            line-height: 48px;
          }
        }
        .goodsInfo_info {
          height: 27px;
          font-size: 28px;
          font-family: PingFang SC;
          font-weight: 500;
          color: rgba(136, 136, 136, 1);
          line-height: 48px;
          margin-top: 22px;
        }
        .goodsInfo_price {
          display: block;
          height: 36px;
          margin-top: 39px;
          font-size: 38px;
          font-family: PingFang SC;
          font-weight: bold;
          color: rgba(255, 59, 62, 1);
        }
      }
      .sell_section_rules {
        width: 100%;
        height: 90px;
        padding: 30px;
        .go_rules {
          .words {
            float: right;
            height: 25px;
            font-size: 26px;
            font-family: PingFang SC;
            font-weight: 400;
            color: rgba(136, 136, 136, 1);
          }
          .arrow {
            float: right;
            margin-left: 10px;
            font-size: 26px;
            font-weight: 400;
            color: rgba(136, 136, 136, 1);
          }
        }
      }
    }
  }
  .quality_section {
    width: 100%;
    margin-top: 20px;
    background: rgba(255, 255, 255, 1);
    .title_top {
      height: 120px;
      padding: 39px 0 39px 30px;
      .title_top_show {
        font-size: 42px;
        font-family: PingFang SC;
        font-weight: bold;
        color: rgba(51, 51, 51, 1);
      }
    }
    .goods_code_group {
      height: 120px;
      padding: 0 30px;
      .goods_code {
        height: 23px;
        margin-bottom: 18px;
        font-size: 24px;
        font-family: PingFang SC;
        font-weight: 300;
        color: rgba(136, 136, 136, 1);
        .code_title {
          font-weight: 500;
        }
      }
    }
    .quality_report {
      width: 100%;
      padding: 0 30px;
      padding-bottom: 49px;
    }
  }
  .footer_btn {
    position: fixed;
    bottom: 0;
    width: 749px;
    height: 97px;
    background: rgba(255, 255, 255, 1);
    .btn {
      width: 199px;
      height: 97px;
      float: right;
      // background:linear-gradient(0deg,rgba(255,127,63,0.83));
      background-color: #ff3b3e;
      font-size: 28px;
      font-family: Adobe Heiti Std;
      font-weight: normal;
      color: rgba(255, 255, 255, 1);
    }
  }
}
</style>
